package de.baumann.browser.adapter;

import android.annotation.SuppressLint;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.math.BigDecimal;

import de.baumann.browser.R;
import de.baumann.browser.api.net.vo.OdinValue;

@SuppressWarnings("ALL")
public class OdinRecordAdapter extends BaseQuickAdapter<OdinValue, BaseViewHolder> {
    public OdinRecordAdapter(int layoutResId) {
        super(layoutResId);
    }

    @SuppressWarnings("AliDeprecation")
    @SuppressLint("SetTextI18n")
    @Override
    protected void convert(BaseViewHolder helper, OdinValue item) {
        TextView tvRecordName = helper.getView(R.id.tvRecordName);
        TextView tvRecordTime = helper.getView(R.id.tvRecordTime);
        TextView tvRecordValue = helper.getView(R.id.tvRecordValue);

        tvRecordName.setText(item.getSourceName());
        tvRecordTime.setText(item.getSourceTime());
        BigDecimal bigDecimal = new BigDecimal(item.getSourceValue());
        if (item.getOperateType() == 1) {
            tvRecordValue.setTextColor(mContext.getResources().getColor(R.color.green_29FFBB));
            tvRecordValue.setText("+ " + bigDecimal.setScale(4, BigDecimal.ROUND_HALF_UP));
        } else {
            tvRecordValue.setTextColor(mContext.getResources().getColor(R.color.color_txt_red));
            tvRecordValue.setText("- " + bigDecimal.setScale(4, BigDecimal.ROUND_HALF_UP));
        }
    }
}
